package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.WarehouseDetailsInfo;
import com.guigu.pojo.WarehouseInfo;
import com.guigu.service.WarehouseDetailsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/warehouseDetailsInfo/")
public class WarehouseDetailsInfoController {
    //自动注入
    @Autowired
    WarehouseDetailsInfoService warehouseDetailsInfoService;

    //分页查询
    @GetMapping("warehouseDetailsInfo.action")
    public Page<WarehouseDetailsInfo> queryAll(WarehouseDetailsInfo warehouseDetailsInfo,
                                             @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                             @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return warehouseDetailsInfoService.queryAll(warehouseDetailsInfo,pageno,pagesize);
    }

    //将供应商商品配置到仓库详情内，需要审核
    @PutMapping("configWarehouseInfo.action")
    public Map configWarehouseInfo(@RequestBody WarehouseDetailsInfo warehouseDetailsInfo){
        return  warehouseDetailsInfoService.configWarehouseInfo(warehouseDetailsInfo);
    }

    //商品分配到仓库的审核【仓库商品配置审批】
    @PostMapping("checkWarehouseDetailsInfo.action")
    public Map checkWarehouseDetailsInfo(@RequestBody WarehouseDetailsInfo warehouseDetailsInfo){
        return  warehouseDetailsInfoService.checkWarehouseDetailsInfo(warehouseDetailsInfo);
    }

    //曹科 根据父id来查询
    @GetMapping("queryAllByPId.action")
    public Page queryAllByPId(WarehouseDetailsInfo warehouseDetailsInfo,
                              @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                              @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return warehouseDetailsInfoService.queryAllByPId(warehouseDetailsInfo,pageno,pagesize);
    }
    // 根据商品id来查询仓库表
    @PostMapping("queryAllshopid.action")
    public com.guigu.service.utils.Page queryAllshopid(@RequestBody WarehouseDetailsInfo warehouseDetailsInfo,
                               @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                               @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return warehouseDetailsInfoService.queryAllshopid(warehouseDetailsInfo,pageno,pagesize);
    }
    // 调拨
    @GetMapping("warehuseDetailsinfoallocate.action")
    public Map warehuseDetailsinfoallocate(Integer aid,Integer bid,Integer max){
        System.out.println("aid:"+aid);
        System.out.println("bid:"+bid);
        System.out.println("max:"+max);
        return warehouseDetailsInfoService.warehuseDetailsinfoallocate(aid,bid,max);
    }
}
